package polyu.comp;

import java.util.*;

import android.graphics.*;

import com.google.android.maps.*;

public class RunPathOverlay extends Overlay {
	

	private Vector<GeoPoint> mGeoPoints;
	
	public Vector<GeoPoint> getmGeoPoints() {
		return mGeoPoints;
	}

	public void setmGeoPoints(Vector<GeoPoint> mGeoPoints) {
		this.mGeoPoints = mGeoPoints;
	}
	
	public RunPathOverlay() {
		
        this.mGeoPoints = new Vector<GeoPoint>();
        
        GeoPoint gP1 = new GeoPoint(22304460, 114180530);
        GeoPoint gP2 = new GeoPoint(22299590, 114180230);
        GeoPoint gP3 = new GeoPoint(22295350, 114175260);
        
        this.mGeoPoints.add(gP1);
        this.mGeoPoints.add(gP2);
        this.mGeoPoints.add(gP3);
		
	}

	public void draw(Canvas canvas, MapView mapv, boolean shadow){
        super.draw(canvas, mapv, shadow);
        
        // Basic Configuration
        
        Projection projection = mapv.getProjection();
        Paint   mPaint = new Paint();
        Path path = new Path();
        
        mPaint.setDither(true);
        mPaint.setColor(Color.BLUE);
        mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mPaint.setStrokeJoin(Paint.Join.ROUND);
        mPaint.setStrokeCap(Paint.Cap.ROUND);
        mPaint.setStrokeWidth(5);

        // Axis Convert
        Point[] pts = new Point[this.mGeoPoints.size()];
        
        for (int i = 0; i < pts.length; i++) {
        	pts[i] = new Point();
        	projection.toPixels(this.mGeoPoints.get(i), pts[i]);
        }

        for (int i = 0; i < pts.length - 1; i++) {
        	path.moveTo(pts[i].x, pts[i].y);
            path.lineTo(pts[i+1].x, pts[i+1].y);
        }
        
        canvas.drawPath(path, mPaint);
        
    }


}
